﻿#ifndef CLIENT_H
#define CLIENT_H

#include <QObject>
#include <httppostrequest.h>
#include <QJsonArray>
#include <QJsonObject>
//#include <widget.h>

class Client : public QObject
{
    Q_OBJECT
public:
    explicit Client(QObject *parent = 0);

signals:
    void handle_get_all_food_finished();
    void handle_get_all_order_by_client_id_finished();
    void handle_get_all_food_style_finished();
    void handle_send_order_finished();
    void send_order_finished_signal();
    void get_all_order_by_client_id_signal();

public slots:
    void client_modify_info_finished();
    void get_client_info_finished();
    void get_all_food_finished();
    void get_all_order_by_client_id_finished();
    void get_all_food_style_finished();
    void send_order_finished();

public:
    void client_modify_info(QJsonObject &data);
    void get_client_info(QString token, int uid);
    HttpPostRequest *request = new HttpPostRequest();
    HttpPostRequest *food_request = new HttpPostRequest();
    HttpPostRequest *order_request = new HttpPostRequest();
    int uid;
    int id;
    QString jwt_token;
    QString name;
    QString phone;
    int prefer;
    QString sex;
    QJsonArray food_list;
    QJsonArray order_list;

    void get_all_food();
    void get_all_order_by_client_id();
    void get_all_food_style();
    void send_order(QJsonArray orders);
};

#endif // CLIENT_H
